<!DOCTYPE html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<style>
img {
  float: left;
  width: 400px;
  height: 200px;
  background: orange;
}
#scroll {
  clear: both;
  height: 200vh;
}
</style>
<div>
  <span>
    <a href="#scroll">
      <img id="click" src="">
    </a>
    &nbsp;
  </span>
</div>
<div id="scroll"></div>
<script>
if (window.chrome && chrome.gpuBenchmarking) {
  let t = async_test('Test floating objects in a-tag.');
  runTest((x, y) => {
    chrome.gpuBenchmarking.pointerActionSequence([
    {"source": "mouse",
      "actions":[
        {"name": "pointerMove", "x": x, "y": y},
        {"name": "pointerDown", "x": x, "y": y},
        {"name": "pointerUp"}]}],
    () => {
      t.step(checkTestResult);
      t.done();
    });
  })
}

function runTest(click_func) {
  let click = document.getElementById('click');
  let bounds = click.getBoundingClientRect();
  let x = (bounds.x + bounds.width) / 2;
  let y = (bounds.y + bounds.height) / 2;
  click_func(x, y);
}

function checkTestResult() {
  let scroll = document.getElementById('scroll');
  assert_equals(document.documentElement.scrollTop, scroll.offsetTop);
}
</script>
